<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" href="/css/style.css">
</head>
<body>
<form method="post" action="/user/regist" id="registerForm">
    <div class="login">
        <h1>图书商城系统</h1>
        <div class="login_box1">
            <h3>用户类型：</h3>
            <input name="user_type" type="text" placeholder="用户类型">
        </div>
        <div class="login_box2">
            <h3>性别：</h3>
            <input name="sex"  type="text" placeholder="请输入性别">
        </div>
        <div class="login_box3">
            <h3>用户名：</h3>
            <input name="name" id="name" type="text" placeholder="请输入用户名">
        </div>
        <div class="login_box4">
            <h3>密码：</h3>
            <input name="password" id="password" type="password" placeholder="请输入密码">
        </div>
        <div class="login_box5">
            <h3 >确认密码：</h3>
            <input name="checkPassword" id="checkPassword" type="password" placeholder="请再次输入密码">
        </div>
        <div class="login_box6">
            <h3>邮箱：</h3>
            <input name="email"  type="text" placeholder="请输入邮箱">
        </div>
        <div class="login_box7">
            <input type="button" value="注册" onclick="registerFun()">
        </div>
    </div>
</form>
<script>
    function registerFun() {
        var name = document.getElementById("name").value;
        var password = document.getElementById("password").value;
        var checkPassword = document.getElementById("checkPassword").value;
        //是否输入且输入是否为空
        if (name != null && name.length != 0 && password != null && password.length != 0) {
            if (password != checkPassword) {
                alert("两次输入的密码不同请重新输入");
            } else {
                var form = document.getElementById("registerForm");
                form.submit();
            }
        } else {
            alert("用户名或密码不能为空");
        }
    }
</script>
</body>
</html>